<?php
/**
 * Created by PhpStorm.
 * User: pt
 * Date: 2018/8/6
 * Time: 9:41
 */

namespace app\admin\controller;


use app\self\controller\Extend;
use think\Db;

/**
 * 部门管理
 * Class Department
 * @package app\admin\controller
 */
class Department extends Extend
{

    public $database = 's_department';

    public $type = '部门管理';


    public function searchWhere()
    {

        $search = [
            ['field'=>'name','name'=>'名称'],
        ];
        $this->assign('search',$search);
        $this->assign('searchJs',json_encode($search));

    }

    public function mapSelf()
    {
        return ['is_delete'=>0];
    }

    public function getField()
    {
        $id = input('id/d',0);
        $result = DB::name($this->database)
            ->where(['id'=>$id])
            ->find();
        $edit = [

            ['field'=>'name','name'=>'名称','value'=>$result['name']],
            ['field'=>'status','name'=>'状态','value'=>empty($result['status'])? 0 : $result['status'],'type'=>'select','option'=>['正常','禁用']],
            ['field'=>'remark','name'=>'备注','value'=>$result['remark']],
        ];
        return $edit;
    }

    public function postVerification($data,$id)
    {

        if(empty($data['name'])) return fieldEmpty('名称'); //字段不能为空

    }


}